#pragma once

#include "rewine/impl/CImage.hpp"
#include "rewine/impl/CPeImage.hpp"

namespace rewine
{

class MapIndicator;

class CDllsoImage : public CImage {
private:

    using dl_handle_t = void *;
    std::shared_ptr<dl_handle_t>    m_Handle = nullptr;
    std::shared_ptr<CPeImage>       m_PeImage = nullptr;

public:

    CDllsoImage() = default;
    ~CDllsoImage() override = default;

public:

    int init(const std::string &fullname);
    int preload();
    int load();
    int unload();

public:

    ImageFlavour flavour() const override {
        return ImageFlavour::DLLSO;
    }

    int getExportCount() const override;
    IExport * getExportByIndex(unsigned int index) const override;
    IExport * getExportByName(const std::string& name, uint16_t hint) const override;

public:

    void *getSymbolInDSO(const char *name) const;

};

} // namespace rewine
